package com.transaction.manage.controller;

import com.transaction.common.base.BaseController;
import com.transaction.common.base.PageInfo;
import com.transaction.common.util.ParamsUtil;
import com.transaction.manage.model.dto.FlowInfo;
import com.transaction.manage.model.dto.FundInfo;
import com.transaction.manage.service.SystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@RequestMapping("/system")
@RestController
@ApiIgnore
public class SystemController extends BaseController {


    @Autowired
    private SystemService systemService;

    /**
     * 查询流程配置信息
     * @param request
     * @return
     */
    @GetMapping("/selectFlowInfoList")
    public Object selectFlowInfoList(HttpServletRequest request){
        FlowInfo flowInfo = ParamsUtil.getBeanParam(new FlowInfo(),request);
        PageInfo pageInfo = ParamsUtil.getPageInfo(request);
        List<FlowInfo> flowInfoList = systemService.selectFlowInfoList(flowInfo,pageInfo);
        pageInfo.setPageResult(flowInfoList);
        return pageInfo;
    }

    /**
     * 查询flowModal的所有下拉
     * @return
     */
    @GetMapping("/selectFlowInfoModalAllCombobox")
    public Object selectFlowInfoModalAllCombobox(){
        Map<String,Object> map = systemService.selectFlowInfoModalAllCombobox();
        return retResultVo(map);
    }

    /**
     * 保存流程信息
     * @param flowInfo
     * @return
     */
    @PostMapping("/saveFlowInfo")
    public Object saveFlowInfo(@RequestBody FlowInfo flowInfo){
        systemService.saveFlowInfo(flowInfo);
        return retResultVo("保存成功！");
    }
}
